package com.hliushi.learn.config;

import liquibase.integration.spring.SpringLiquibase;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * @ClassName LiquibaseConfig
 * @Description TODO
 * @Author hliushi
 * @Date 2021/7/14 20:33
 * @Version V1.0
 **/
@Configuration
public class LiquibaseConfig {

    /**
     * 配置SpringLiquibaseBean
     *
     * @param dataSource
     * @return SpringLiquibase
     **/
    @Bean
    public SpringLiquibase liquibase(DataSource dataSource) {
        SpringLiquibase liquibase = new SpringLiquibase();
        liquibase.setDataSource(dataSource);
        // 指定changelog的位置, 这里使用的一个master文件引用其他文件的方式
        liquibase.setChangeLog("classpath:liquibase/master.xml");
        liquibase.setShouldRun(true);

        return liquibase;
    }


}
